﻿// BooTasky is a small tools which use RememberTheMilk web services.
// Copyright (C) BooTasky of Yan-ren Tsai
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

namespace BooTasky

import System
import System.Collections.Generic
import RtmNet

class RtmTask(ITask):
"""Description of RtmTask"""
	private _dateFormatString as string = "yyyy-MM-ddTHH:mm:ssZ"
	
	Name as string:
		get:
			return _taskSeries.Name
		set:
			pass

	DueDate as DateTime:
		get:
			return _taskSeries.Task.Due.ToUniversalTime()
			//return _taskSeries.Task.Due.ToUniversalTime().ToString( _dateFormatString )
		set:
			pass
	
	CompletionDate as DateTime:
		get:
			return _taskSeries.Task.Completed.ToUniversalTime()
			//return _taskSeries.Task.Completed.ToUniversalTime().ToString( _dateFormatString )
		set:
			pass

	IsComplete as bool:
		get:
			return _state==TaskState.Completed		

	Priority as TaskPriority:
		get:
			return _priorityHash[ _taskSeries.Task.Priority ]
		set:
			pass

	HasNotes as bool:
		get:
			return _taskSeries.Notes.NoteCollection.Length > 0

	ID as string:
		get:
			return _taskSeries.TaskID

	_category as ICategory = null

	Category as ICategory:
		get:
			return _category
		set:
			pass

	_state as TaskState
	
	State as TaskState:
		get:
			return _state
		set:
			pass
	
	[property(Notes)]
	_notes as List of INote

	_taskSeries as TaskSeries
	
	_priorityHash = {}
	
	def constructor( taskSeries as TaskSeries, category as ICategory):
		_taskSeries = taskSeries
		_category = category

		if CompletionDate == DateTime.MinValue:		
			_state = TaskState.Active
		else:
			_state = TaskState.Completed
		
		_priorityHash["N"] = TaskPriority.None
		_priorityHash["1"] = TaskPriority.High
		_priorityHash["2"] = TaskPriority.Medium
		_priorityHash["3"] = TaskPriority.Low 

	def CompareTo( other as ITask) as int:
		return Priority.CompareTo( other.Priority )
